package com.code.day14;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.Temporal;
import java.time.temporal.TemporalAccessor;

public class Day14DateTimeFormatter {
    public static void main(String[] args) {
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDateTime time1 = LocalDateTime.of(2019,10,10,10,10,10);
        String format =dateTimeFormatter.format(time1);
        System.out.println("format = " + format);

        String str = "2019-10-10 10:10:10";
        DateTimeFormatter dateTimeFormatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
//        LocalDateTime localDateTime = LocalDateTime.parse(str,dateTimeFormatter2);
//        System.out.println("localDateTime = " + localDateTime);
        TemporalAccessor temporalAccessor = dateTimeFormatter2.parse(str);
        LocalDateTime from = LocalDateTime.from(temporalAccessor);
        System.out.println(from);

    }
}
